//
//  UIImage+Extend.h
//  SelectPhoto
//
//  Created by bianruifeng on 14/12/5.
//  Copyright (c) 2014年 bian. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>


@interface UIImage (Extend)

/**
 *  @author bianruifeng, 16-09-04 11:09:59
 *
 *  @brief 获得一个圆形的图片  UIImage *placeHolder = [[UIImage imageNamed:@"defaultUserIcon"] circleImage];
 *
 *  @return 返回一个圆角图片
 */
- (UIImage *)circleImage;


/**
 *  拉伸图片:自定义比例
 */
+(UIImage *)resizeWithImageName:(NSString *)name leftCap:(CGFloat)leftCap topCap:(CGFloat)topCap;





/**
 *  拉伸图片
 */
+(UIImage *)resizeWithImageName:(NSString *)name;




/**
 *  保存相册
 *
 *  @param completeBlock 成功回调
 *  @param completeBlock 出错回调
 */
-(void)savedPhotosAlbum:(void(^)())completeBlock failBlock:(void(^)())failBlock;


/**
 *  压缩图片到指定尺寸
 */
+ (UIImage *)ImageCompress:(UIImage*)imge scaleToSize:(CGSize)size;


/**
 *  压缩图片到限定范围内
 */
+ (UIImage *)ImageCompress:(UIImage *)image limitToSize:(CGSize)lsize;


/**
 *  返回一个纯色的image
 */
+(UIImage *)imageWithColor:(UIColor *)color;


/**
 *  获得视频针的截图
 */
+ (UIImage*)thumbnailImageForVideo:(NSURL *)videoURL atTime:(NSTimeInterval)time;


/*!
 * @brief 根据指定的Rect来截取图片，返回截取后的图片
 * @param rect 指定的Rect，如果大小超过图片大小，就会返回原图片
 * @return 返回截取后的图片
 */
- (UIImage *)subImageWithRect:(CGRect)rect;

/*!
 * @brief 把图片等比例缩放到指定的size
 * @param size 缩放后的图片的大小
 * @return 返回缩放后的图片
 */
- (UIImage *)scaleToSize:(CGSize)size;


/**
 *  根据UIImage 的信息 转正
 *
 *  @param aImage UIImage
 *
 *  @return 正向的UIImage
 */

-(UIImage *)fixOrientation;


- (UIImage *)bhb_applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage;


@end
